﻿@using KPIS.GERP.Models.SYS.Resources
@model KPIS.GERP.Models.ICM.PurchaseRequestItem

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "รายการขอซื้อ/จ้าง";
    ViewBag.Descr = "รายการขอซื้อ ขอจ้าง ที่ทางพัสดุทำรายการจากการแจ้งความประสงค์ฯ";
}

@using (Html.BeginForm("Edit", "PurchaseItem", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.AntiForgeryToken()

    <div class="block-button-menu-above">
        @Html.ActionLink("กลับไปหน้าแสดงข้อมูลทั้งหมด", "Index", new { PrId = Model.PrId }, new { @class = "btn btn-gray button-standard-width btn-small", role="button" })
        @Html.ButtonSubmit()
       @* @Html.ButtonCancel(new { Id = Model.PrItemId })*@
    </div>
    
    @Html.ValidationSummary(true, "", new { @class = "alert alert-error" })
    @Html.Partial("_EditorForm")
}

@section scripts
{
    <script>
        $("form").submit(function (e) {
            e.preventDefault();
            var currentForm = this;
            bootbox.confirm(function (result) {
                if (result) {
                    currentForm.submit();
                }
            });
        });

        $(function () {

            $("#lblPrice").change(function () {
                var price = $("#lblPrice").val();
                var qty = $("#lblQty").val();
                var lblAmount = $("#lblAmount");

                if (price == "") {
                    price = 0;
                }

                if (qty == "") {
                    qty = 0;
                }

                lblAmount.val(price * qty);
            });

            $("#lblQty").change(function () {
                var price = $("#lblPrice").val();
                var qty = $("#lblQty").val();
                var lblAmount = $("#lblAmount");

                if (price == "") {
                    price = 0;
                }

                if (qty == "") {
                    qty = 0;
                }

                lblAmount.val(price * qty);
            });
        });
    </script>
}